﻿using BattleBotsMattAndSunny.Model;
using BattleBotsMattAndSunny.Utilities;
using Robocode;

namespace BattleBotsMattAndSunny.Extensions
{
    public static class RobotExtensions
    {
        public static void LockOn(this Robot r, double targetHeading)
        {
            r.Turn(CommonActions.GetCorrection(targetHeading, r.Heading));
            r.TurnGun(CommonActions.GetCorrection(targetHeading, r.GunHeading));
        }

        public static void Turn(this Robot r, TurnCorrection c)
        {
            switch (c.Direction)
            {
                case TurnDirection.Left:
                    r.TurnLeft(c.Degrees);
                    break;

                case TurnDirection.Right:
                    r.TurnRight(c.Degrees);
                    break;
            }
        }

        public static void TurnGun(this Robot r, TurnCorrection c)
        {
            switch (c.Direction)
            {
                case TurnDirection.Left:
                    r.TurnGunLeft(c.Degrees);
                    break;

                case TurnDirection.Right:
                    r.TurnGunRight(c.Degrees);
                    break;
            }
        }
    }
}